//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet
{
    public class CustomWorkbookView : IOfficeXmlSerializable
    {
        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read("customWorkbookView"))
            {
                Name = c.GetString("name");
                guid = c.GetString("guid");
                autoUpdate = c.GetOptionalBoolean("autoUpdate", false);
                mergeInterval = c.GetOptionalInteger("mergeInterval", 0);
                changesSavedWin = c.GetOptionalBoolean("changesSavedWin", false);
                onlySync = c.GetOptionalBoolean("onlySync", false);
                personalView = c.GetOptionalBoolean("personalView", false);
                includePrintSettings = c.GetOptionalBoolean("includePrintSettings", true);
                includeHiddenRowCol = c.GetOptionalBoolean("includeHiddenRowCol", true);
                maximized = c.GetOptionalBoolean("maximized", false);
                minimized = c.GetOptionalBoolean("minimized", false);
                showHorizontalScroll = c.GetOptionalBoolean("showHorizontalScroll", true);
                showVerticalScroll = c.GetOptionalBoolean("showVerticalScroll", true);
                _showSheetTabs = c.GetOptionalBoolean("showSheetTabs", true);
                xWindow = c.GetOptionalInteger("xWindow", 0);
                yWindow = c.GetOptionalInteger("yWindow", 0);
                windowWidth = c.GetUIntegerAsInteger("windowWidth");
                windowHeight = c.GetUIntegerAsInteger("windowHeight");
                tabRatio = c.GetOptionalUIntegerAsInteger("tabRatio", 600);
                activeSheetId = c.GetUIntegerAsInteger("activeSheetId");
                showFormulaBar = c.GetOptionalBoolean("showFormulaBar", true);
                showStatusbar = c.GetOptionalBoolean("showStatusbar", true);
                showComments = c.GetOptionalEnum("showComments", CommentsDisplayType.Indicator);
                showObjects = c.GetOptionalEnum("showObjects", ObjectDisplayType.All);
                Extension = c.ReadOptionalElement<ExtensionElement>("extLst");
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("customWorkbookView"))
            {
                c.SetString("name", Name);
                c.SetString("guid", guid);
                c.SetOptionalBoolean("autoUpdate", autoUpdate, false);
                c.SetOptionalInteger("mergeInterval", mergeInterval, 0);
                c.SetOptionalBoolean("changesSavedWin", changesSavedWin, false);
                c.SetOptionalBoolean("onlySync", onlySync, false);
                c.SetOptionalBoolean("personalView", personalView, false);
                c.SetOptionalBoolean("includePrintSettings", includePrintSettings, true);
                c.SetOptionalBoolean("includeHiddenRowCol", includeHiddenRowCol, true);
                c.SetOptionalBoolean("maximized", maximized, false);
                c.SetOptionalBoolean("minimized", minimized, false);
                c.SetOptionalBoolean("showHorizontalScroll", showHorizontalScroll, true);
                c.SetOptionalBoolean("showVerticalScroll", showVerticalScroll, true);
                c.SetOptionalBoolean("showSheetTabs", _showSheetTabs, true);
                c.SetOptionalInteger("xWindow", xWindow, 0);
                c.SetOptionalInteger("yWindow", yWindow, 0);
                c.SetUIntegerAsInteger("windowWidth", windowWidth);
                c.SetUIntegerAsInteger("windowHeight", windowHeight);
                c.SetOptionalUIntegerAsInteger("tabRatio", tabRatio, 600);
                c.SetUIntegerAsInteger("activeSheetId", activeSheetId);
                c.SetOptionalBoolean("showFormulaBar", showFormulaBar, true);
                c.SetOptionalBoolean("showStatusbar", showStatusbar, true);
                c.SetOptionalEnum("showComments", showComments, CommentsDisplayType.Indicator);
                c.SetOptionalEnum("showObjects", showObjects, ObjectDisplayType.All);
                c.WriteOptionalElement(Extension);
            }
        }

        #endregion

        private ExtensionElement _extension;

        public ExtensionElement Extension
        {
            get { return _extension; }
            set { _extension = value; }
        }
	

        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private string guid; //\\       

        public string Guid
        {
            get { return guid; }
            set { guid = value; }
        }
        private bool autoUpdate;

        public bool AutoUpdate
        {
            get { return autoUpdate; }
            set { autoUpdate = value; }
        }
        private int mergeInterval;

        public int MergeInterval
        {
            get { return mergeInterval; }
            set { mergeInterval = value; }
        }
        private bool changesSavedWin;

        public bool ChangesSavedWin
        {
            get { return changesSavedWin; }
            set { changesSavedWin = value; }
        }
        private bool onlySync;

        public bool OnlySync
        {
            get { return onlySync; }
            set { onlySync = value; }
        }
        private bool personalView;

        public bool PersonalView
        {
            get { return personalView; }
            set { personalView = value; }
        }
        private bool includePrintSettings = true;

        public bool IncludePrintSettings
        {
            get { return includePrintSettings; }
            set { includePrintSettings = value; }
        }
        private bool includeHiddenRowCol = true;

        public bool IncludeHiddenRowCol
        {
            get { return includeHiddenRowCol; }
            set { includeHiddenRowCol = value; }
        }
        private bool maximized;

        public bool Maximized
        {
            get { return maximized; }
            set { maximized = value; }
        }
        private bool minimized;

        public bool Minimized
        {
            get { return minimized; }
            set { minimized = value; }
        }

        private bool showHorizontalScroll = true;

        public bool ShowHorizontalScroll
        {
            get { return showHorizontalScroll; }
            set { showHorizontalScroll = value; }
        }

        private bool showVerticalScroll = true;

        public bool ShowVerticalScroll
        {
            get { return showVerticalScroll; }
            set { showVerticalScroll = value; }
        }

        private bool _showSheetTabs = true;

        public bool ShowSheetTabs
        {
            get { return _showSheetTabs; }
            set { _showSheetTabs = value; }
        }
        private int xWindow;

        public int XWindow
        {
            get { return xWindow; }
            set { xWindow = value; }
        }
        private int yWindow;

        public int YWindow
        {
            get { return yWindow; }
            set { yWindow = value; }
        }
        private int windowWidth;

        public int WindowWidth
        {
            get { return windowWidth; }
            set { windowWidth = value; }
        }
        private int windowHeight;

        public int WindowHeight
        {
            get { return windowHeight; }
            set { windowHeight = value; }
        }
        private int tabRatio = 600;

        public int TabRatio
        {
            get { return tabRatio; }
            set { tabRatio = value; }
        }
        private int activeSheetId;

        public int ActiveSheetId
        {
            get { return activeSheetId; }
            set { activeSheetId = value; }
        }
        private bool showFormulaBar = true;

        public bool ShowFormulaBar
        {
            get { return showFormulaBar; }
            set { showFormulaBar = value; }
        }
        private bool showStatusbar = true;

        public bool ShowStatusBar
        {
            get { return showStatusbar; }
            set { showStatusbar = value; }
        }
        private CommentsDisplayType showComments;

        public CommentsDisplayType ShowComments
        {
            get { return showComments; }
            set { showComments = value; }
        }
        private ObjectDisplayType showObjects;

        public ObjectDisplayType ShowObjects
        {
            get { return showObjects; }
            set { showObjects = value; }
        }

    }
}
